//
//Copyright 2009 Google Inc.
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//

/**
 * @fileoverview This is an HTML widget, which allows to share link of this
 * page.
 */

/** name of the div that contains the link id */
var LINK_ID_DIV = 'le';

/** name of the div that contains the link url */
var LINK_ID_URL = 'leurl';

/** name of the div that contains the link to this page */
var LINK_ID_LINK_TO_PAGE = 'link';

/**
 * Creates a new sharelink widget. This widget displays the link to share for
 * the current landing page.
 * @constructor
 */
digitalContentWizard.ShareLink = function() {
  /**
   * Link ID div element.
   * @type {HTMLElement}
   * @private
   */
  this.linkIdDiv_ = document.getElementById(LINK_ID_DIV);
  /**
   * Link to page div element.
   * @type {HTMLElement}
   * @private
   */
  this.linkToPageDiv_ = document.getElementById(LINK_ID_LINK_TO_PAGE);
  /**
   * page url div element.
   * @type {HTMLElement}
   * @private
   */
  this.linkUrlDiv_ = document.getElementById(LINK_ID_URL);
};

/**
 * Displays the link to this page div.
 */
digitalContentWizard.ShareLink.prototype.show = function() {
  this.linkIdDiv_.style.display = 'block';
  this.linkUrlDiv_.value = this.linkToPageDiv_.href;
  this.linkUrlDiv_.focus();
  this.linkUrlDiv_.select();
};

/**
 * Hides the link to this page div.
 */
digitalContentWizard.ShareLink.prototype.hide = function() {
  this.linkIdDiv_.style.display = 'none';
};

